/**
 * 
 */
package com.jeecms.wicool.entity.killBuy;

import java.sql.Timestamp;
import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.jeecms.wicool.entity.killBuy.base.AbstractKillBuy;

/**
 * @author spring
 *
 */
public class KillBuy extends AbstractKillBuy {

	/**
	 * 
	 */
	private static final long serialVersionUID = -487218745811004006L;
	
	private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");

	public String getStartTimeStr() {
		if(getStartTime() == null){
			setStartTime(new Timestamp(new Date().getTime()));
		}
		return formatter.print(getStartTime().getTime());
	}

	public void setStartTimeStr(String startTimeStr) {
		if(StringUtils.isBlank(startTimeStr)){
			setStartTime(new Timestamp(new Date().getTime()));
		}else{
			setStartTime(new Timestamp(DateTime.parse(startTimeStr, formatter).getMillis()));
		}
	}

	public String getEndTimeStr() {
		if(getEndTime() == null){
			setEndTime(new Timestamp(new Date().getTime()));
		}
		return formatter.print(getEndTime().getTime());
	}

	public void setEndTimeStr(String endTimeStr) {
		if(StringUtils.isBlank(endTimeStr)){
			setEndTime(new Timestamp(new Date().getTime()));
		}else{
			setEndTime(new Timestamp(DateTime.parse(endTimeStr, formatter).getMillis()));
		}
	}
	
	public String getUsetimeStr() {
		if(getEndTime() == null){
			setUsetime(new Timestamp(new Date().getTime()));
		}
		return formatter.print(getUsetime().getTime());
	}

	public void setUsetimeStr(String usetimeStr) {
		if(StringUtils.isBlank(usetimeStr)){
			setUsetime(new Timestamp(new Date().getTime()));
		}else{
			setUsetime(new Timestamp(DateTime.parse(usetimeStr, formatter).getMillis()));
		}
	}

}
